package com.thread;

import java.util.Scanner;

/**
 * 实现一个简易的倒计时程序程序启动后要求用户在控制台上输入一个整数，然后从该数字开始每秒递减到0时输出时间到
 */
public class SleepDemo2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要订的倒计时闹钟，单位/s");
        int i = scanner.nextInt();
        try {
            for (int j = i; j <= i; j--) {
                if (j <= 0) {
                    break;
                }
                Thread.sleep(1000);
                System.out.println("倒计时" + j + "s");
            }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("时间到");
    }
}
